package tests;

import data.UUIDData;

import java.util.UUID;
import java.io.FileOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;

import packet.UUIDPacket;
import packet.PktCtlMsg;
import packet.Packet;

/**
 * Created by IntelliJ IDEA.
 * User: qiukexu
 * Date: 2009-6-5
 * Time: 14:55:05
 * Company: Shanghai Fastech Co.,Ltd.
 */
public class TestOutput {
    public static void main(String[] args) throws IOException {
        UUIDData uuidData = new UUIDData();
        UUID uuid = UUID.randomUUID();
        uuidData.setUuid(uuid);

        PktCtlMsg pktCtlMsg = new PktCtlMsg();

        UUIDPacket packet = new UUIDPacket();
        packet.setPktCtlMsg(pktCtlMsg);
        packet.setErrorCode((short)0);
        packet.setPacketType(Packet.TYPE_UUID_REQ);
        packet.setData(uuidData);

        pktCtlMsg.setCmd(1001);
        pktCtlMsg.setLen(pktCtlMsg.getPackLeng()+2+uuidData.getPackLeng());

        FileOutputStream fos = new FileOutputStream(new File("D:\\out.bin"));
        fos.write(packet.toBinaryData());
        fos.flush();
        fos.close();
    }
}
